package com.example.demo;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.example.demo.pojo.SealAllVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @auther: Wyz
 * @date: 2021/12/5 00:03
 * @return
 */
@RestController
@Slf4j
public class DaoruController {

    @PostMapping(value = "/test", headers = "content-type=multipart/form-data", consumes = "multipart/*")
    public void initSealCf(@RequestParam("filePath") MultipartFile filePath) {
        File file = null;
        try {
            file = filePath.getResource().getFile();
        } catch (IOException e) {
            log.info("解析流异常，异常信息为：{}", e);
        }
        //导入的标题和说明的设置
        ImportParams params = new ImportParams();
        //设置说明
        params.setHeadRows(1);

        //导入获取集合

        List<SealAllVo> sealCfBos = ExcelImportUtil.importExcel(file, SealAllVo.class, params);
        List<Map<String, Integer>> listMap = new ArrayList<>();

    }

}
